
let baseURL = 'http://m.mengxuegu.com/api' 

const http = (params = {}) => {
	//loading条
	uni.showLoading({
		title: '加载中'
	});
	return new Promise((resolve, reject) => {
		uni.request({
			url: baseURL + params.url,
			method: params.method || 'GET',
			data: params.data || {},
			// timeout: 8000, 
			success: (res) => {
				console.log('res', res.data)
				resolve(res.data)
			},
			fail: (err) => {
				uni.showToast({
						title:'请求接口失败',
						duration: 1500,
						mask: false
				})
				reject(err)
			},
		})
	}) 
}

// 导出
export default http